function Deck(){
	this.nextCard = 0;
	this.deck = new Array(suits.length * ranks.length);
	for (var j = 0; j < suits.length; j++) {
		for (var k = 0; k < ranks.length; k++) {
			var nr =  j * ranks.length + k;
			this.deck[nr] = new Card(j, k);
		}
	}
	
	shuffle(this.deck);
	this.giveCard = giveCard;
}

function giveCard() {
	if (this.nextCard < this.deck.length) {
		this.nextCard++;
		return this.deck[this.nextCard - 1];
	}
	return null;
}

function swapCards(d, a, b) {
	temp = d[a];
	d[a] = d[b];
	d[b] = temp;
}

function shuffle(d) {
	for (var i = d.length - 1; i > 0; i--) {
		swapCards(d, i, Math.floor(Math.random()*(i + 1)));
	}
}